<?php

/**
 * SimpleSuggest is a simple recommeder engine used to find
 * tag-related documents.
 */

class folio_SimpleSuggest {

    /**
     * Return an array of related pages
     * @param folio_page $page
     * @param int $limit How many pages to return.
     * @return array Array of folio_pages
     */
    public function RelatedPages( folio_page $page, $limit = 10 ) {
        $pages = array();

        // Find similar pages.
        $tags = folio_tags::SelectWherePageIdent( $page->page_ident );
        $pages = folio_tags::SelectWhereSimilar( $tags, $page, $limit  );

        return $pages;
    }

    /**
     * Return an array of related pages
     * @param folio_tag $tag
     * @param int $start What record to begin returning.
     * @param int $limit How many pages to return.
     * @return array Array of folio_pages
     */
    public function FromTag( $tag, $start = 0, $limit = -1) {

        // Find similar pages.
        $pages = folio_tags::SelectWhereSimilar( array($tag), false, $limit , $start );

        return $pages;
    }

}

?>
